{templateType ApiGen\Renderer\Latte\Template\FunctionTemplate}
{import '../blocks/@index.latte'}

{embed layout}
	{block title}
		{if $function->isDeprecated()}Deprecated {/if}
		{$function->name->full}
	{/block}

	{block content}
		<h1 n:class="$function->isDeprecated() ? deprecated">
			{include functionLinks, $function}
		</h1>

		{if $function->genericParameters}
			<h2><code>{include genericParameters, $function->genericParameters}</code></h2>
		{/if}

		{include functionDescription, $function}

		<div class="classLikeSection" n:if="$function->file && sourcePageExists($index->files[$function->file])">
			<b>Located at</b> <a href="{functionSourceUrl($function)}" title="Go to source code">{relativePath($function->file)}</a>
		</div>

		<table class="table" n:if="$function->parameters">
			<tr>
				<th class="table-heading" colspan="4">Parameters</th>
			</tr>

			{foreach $function->parameters as $parameter}
				<tr id="{parameterAnchor($parameter)}">
					<td class="table-cell table-shrink">
						<code class="nowrap">{if $parameter->type}{include type, $parameter->type}{/if}</code>
					</td>
					<td class="table-cell table-shrink">
						<code class="nowrap" n:pre>
							{if $parameter->byRef}&amp;{/if}{if $parameter->variadic}...{/if}<var>${$parameter->name}</var>
							{if $parameter->default} = {include expr, expr: $parameter->default}{/if}
						</code>
					</td>
					<td class="table-cell">{longDescription($index, null, $parameter->description)}</td>
					<td class="table-anchor">
						<a href="#{parameterAnchor($parameter)}">#</a>
					</td>
				</tr>
			{/foreach}
		</table>

		<table class="table" n:if="$function->byRef || $function->returnType || $function->returnDescription">
			<tr>
				<th class="table-heading" colspan="2">Returns</th>
			</tr>

			<tr>
				<td class="table-cell table-shrink" n:if="$function->byRef || $function->returnType">
					<code class="nowrap">{if $function->byRef}&amp;{/if}{include type, $function->returnType}</code>
				</td>
				<td class="table-cell" n:if="$function->returnDescription">
					{longDescription($index, null, $function->returnDescription)}
				</td>
			</tr>
		</table>

		<table class="table" n:ifset="$function->tags[throws]">
			<tr>
				<th class="table-heading" colspan="2">Throws</th>
			</tr>

			{foreach $function->tags[throws] as $tag}
				<tr>
					<td class="table-cell table-shrink"><code class="nowrap">{include type, type: $tag->type, short: false}</code></td>
					<td class="table-cell" n:if="$tag->description">{longDescription($index, $tag->description)}</td>
				</tr>
			{/foreach}
		</table>
	{/block}
{/embed}
